<?php $this->load->view('common/cms-head'); ?>
<article id="content">
    <div class="pgwrapper">
    <div class="w960 bg1 p15 bx_shw">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
  <td width="20%" style="border-right:2px solid #e5e5e5;" valign="top">
    <?php $this->load->view('enterprises/leftnavCMS'); ?>
  </td>
  <td width="80%" valign="top" style="padding:5px;">
  <form id="cpnForm">
  <table width="100%" cellpadding="5" cellspacing="0" style="padding: 0 30px 20px 30px;border-bottom:1px solid #ccc;">
                    <tr>
						<td class="txt-blck" width="35%"><strong>View Coupons By:</strong></td>
						<td><select id="cpn_by" name="cpn_by"
							onchange="getCouponBy(this.value);" style="width: 200px;padding-top:5px;" class="setBgInput">
								<option <?php if($cpnBy=='rejected'){ echo "selected"; } ?> value="rejected">Rejected</option>
								<option <?php if($cpnBy=='store'){ echo "selected"; } ?> value="store">Store Wise</option>
						</select>
                        </td>
					</tr>
  </table>
  </form>
  <!-- ------------------------ -->
  <?php if(isset($allStoresArray)){?>
  <form id="myform">
  <table width="100%" border="0" cellpadding="5" cellspacing="0" style="padding: 10px 30px;">
                    <tr>
						<td class="txt-blck"><strong>Select Store:</strong></td>
						<td><select id="code_store" name="code_store"
							onchange="getStoreCoupons(this.value);">
							<?php foreach ($allStoresArray as $temp){ ?>
								<option <?php if($temp['store_id']==$storeId){ echo "selected"; } ?> value="<?php echo $temp['store_id']; ?>">
								<?php echo $temp['store_name']; ?>
								</option>
								<?php } ?>
						</select>
                        </td>
					</tr>
  </table>
  </form>
  <?php }?>
  <table width="100%" border="1" cellpadding="5" cellspacing="0" style="margin-top: 10px;">
  <?php if(isset($rejectArray)){ ?>
  <tr style="background-color:#f2f2f2;">
  	<td class="txt-blck"><strong>Store Name</strong></td>
    <td class="txt-blck"><strong>Coupon Title</strong></td>
    <td class="txt-blck" nowrap="nowrap"><strong>Coupon Status</strong></td>
    <td></td>
  </tr>
  <?php foreach ($rejectArray as $codes){?>
  <tr>
    <td class="txt-blck" width="20%"><?php echo $codes['store_name'];?></td>
    <td class="txt-blck" width="60%"><?php echo $codes['coupon_name'];?></td>
    <td class="txt-blck" width="20%" align="center"><?php echo $codes['coupon_status'];?></td>
    <td width="20%" align="center"><a href="/editCoupon/<?php echo $codes['coupon_id'];?>" class="link1">Edit</a></td>
  </tr>
  <?php }} ?>
  <?php if(isset($couponArray)){ ?>
  <tr style="background-color:#f2f2f2;">
    <td class="txt-blck"><strong>Coupon Title</strong></td>
    <td class="txt-blck" nowrap="nowrap"><strong>Coupon Status</strong></td>
    <td></td>
  </tr>
  <?php foreach ($couponArray as $codes){?>
  <tr>
    <td class="txt-blck" width="60%"><?php echo $codes['coupon_name'];?></td>
    <td class="txt-blck" width="20%" align="center"><?php echo $codes['coupon_status'];?></td>
    <td width="20%" align="center"><a href="/editCoupon/<?php echo $codes['coupon_id'];?>" class="link1">Edit</a></td>
  </tr>
  <?php }} ?>
</table>
  </td>
</tr>
</table>
</div>
</div>
</article>
<div class="clr-both spacer-10">&nbsp;</div>
<?php $this->load->view('common/cms-footer'); ?>
<script>
function getCouponBy(a) {
	document.forms.cpnForm.action = "/viewCoupons/" + a+"/0";
	document.forms.cpnForm.submit()
}
function getStoreCoupons(a) {
	document.forms.myform.action = "/viewCoupons/store/" + a;
	document.forms.myform.submit()
}
</script>